package com.mine.java.future.price;

import com.mine.java.future.PrintUtils;

import java.math.BigDecimal;

/**
 * @author weixiao
 * @date 2025/3/27 14:34
 */
public class MockHttpRequest {

    public static PriceResult getPriceResult(String product, String platform) {
        PriceResult priceResult = new PriceResult(platform);
        PrintUtils.print("获取" + platform + "平台，" + product + "价格开始");
        PrintUtils.sleep(1000);
        switch (platform) {
            case "TB":
                priceResult.setOriginalPrice(new BigDecimal(5299));
                priceResult.setDiscount(new BigDecimal(200));
                break;
            case "JD":
                priceResult.setOriginalPrice(new BigDecimal(5399));
                priceResult.setDiscount(new BigDecimal(200));
                break;
            case "PDD":
                priceResult.setOriginalPrice(new BigDecimal(5499));
                priceResult.setDiscount(new BigDecimal(500));
                break;
            default:
                break;
        }
        PrintUtils.print("获取" + platform + "平台，" + product + "价格结束");
        return priceResult;
    }

    public static void calFinalPrice(PriceResult priceResult) {
        PrintUtils.print("计算" + priceResult.getPlatform() + "平台最终价格开始");
        priceResult.setFinalPrice(priceResult.getOriginalPrice().subtract(priceResult.getDiscount()));
        PrintUtils.sleep(500);
        PrintUtils.print("计算" + priceResult.getPlatform() + "平台最终价格结束");
    }

    public static BigDecimal getDisCount(String platform) {
        PrintUtils.print("获取" + platform + "平台折扣开始");
        PrintUtils.sleep(500);
        PrintUtils.print("获取" + platform + "平台折扣结束");
        BigDecimal discount;
        switch (platform) {
            case "TB":
                discount = new BigDecimal(200);
                break;
            case "JD":
                discount = new BigDecimal(300);
                break;
            case "PDD":
                discount = new BigDecimal(500);
                break;
            default:
                discount = new BigDecimal(0);
                break;
        }
        return discount;
    }
}
